/*
 *
 *  * Copyright (c) 2016. For Intelligent Group.
 *
 */

package com.intelligent.ispc.client.core.view.global;

import com.intelligent.ispc.client.ex.ProcessPanel;
import com.intelligent.ispc.client.utils.FontFactory;
import com.intelligent.ispc.client.utils.GBC;
import com.intelligent.ispc.client.utils.ResourceMessages;
import com.intelligent.ispc.common.utils.ResourceBundleUtils;

import javax.annotation.PostConstruct;
import javax.swing.*;
import java.awt.*;

/**
 * Created by Peter on 2016/7/13.
 */
@org.springframework.stereotype.Component
public class MainStateBar extends JPanel {

    /**
     * Constructor
     */
    public MainStateBar() {
    }

    /**
     * Initialize components
     */
    @PostConstruct
    public void initComponents() {
        this.setLayout(new GridBagLayout());
        final Dimension mainDialogSize = new Dimension(200, 15);
        this.setPreferredSize(mainDialogSize);
        lblStateInfo = new JLabel("");
        lblStateInfo.setFont(FontFactory.createStatusInfoFont());
        this.add(lblStateInfo, new GBC(0, 0).setFill(GBC.BOTH).setWeight(25, 100).setIpad(10, 0).setInsets(0, 10, 0, 0));
        this.add(new JSeparator(SwingConstants.VERTICAL), new GBC(1, 0).setFill(GBC.BOTH).setWeight(0, 100).setInsets(3));

        processPanel = new ProcessPanel();
        this.add(processPanel, new GBC(2, 0).setFill(GBC.HORIZONTAL).setWeight(10, 0).setInsets(0, 10, 0, 10));
        this.add(new JSeparator(SwingConstants.VERTICAL), new GBC(3, 0).setFill(GBC.BOTH).setWeight(0, 100).setInsets(3));

        label2 = new JLabel("", JLabel.CENTER);
        label2.setFont(FontFactory.createStatusInfoFont());
        final Dimension label2Size = new Dimension(50, 15);
        label2.setPreferredSize(label2Size);
        this.add(label2, new GBC(4, 0).setFill(GBC.BOTH).setWeight(10, 100));
        this.add(new JSeparator(SwingConstants.VERTICAL), new GBC(5, 0).setFill(GBC.BOTH).setWeight(0, 100).setInsets(3));

        label4 = new JLabel(ResourceBundleUtils.getString(ResourceMessages.APP_VERSION), JLabel.CENTER);
        label4.setFont(FontFactory.createStatusInfoFont());
        final Dimension label4Size = new Dimension(50, 15);
        label4.setPreferredSize(label4Size);
        this.add(label4, new GBC(8, 0).setFill(GBC.BOTH).setWeight(10, 100));
    }

    public void setMessage(String value, Color color) {
        if (color != null) {
            lblStateInfo.setForeground(color);
        }

        lblStateInfo.setText(value);
        lblStateInfo.setForeground(color);
    }

    public void setUser(String value) {
        label2.setText(value);
    }

    public ProcessPanel getProcessPanel() {
        return processPanel;
    }

    private JLabel lblStateInfo;
    private ProcessPanel processPanel;


    private JLabel label2;
    private JLabel label4;

}
